package com.example.demo.threadExecutor;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName: ThreadExecutorDemo
 * @Description:
 * @Author:
 * @Date
 */
public class ThreadExecutorDemo {
    public static void main(String[] args) {
        // 使用submit方式提交任务，有future返回对象，异常会自动抛出
        // 使用execute 无返回对象。
        ThreadPoolExecutor poolExecutor =
                new ThreadPoolExecutor(1, 1, 1, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000));
        poolExecutor.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("submit task");
            }
        });
        poolExecutor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("execute task");
            }
        });
    }
}
